home *** CD-ROM | disk | FTP | other *** search
/ Whiteline: delta / whiteline CD Series - delta.iso / document / hypertxt / ximgtool / mfdb_in.c < prev    next >
C/C++ Source or Header  |  1995-11-25  |  1KB  |  49 lines

  1. #include <vdi.h>
  2.  
  3. #include "imgcodec.h"
  4.  
  5. /* Standard MFDB input processing.
  6.  * This can be used for screen snapshots.
  7.  * The image object is provided by calling an encode_init
  8.  * function. The input_header must thereby match the mfdb,
  9.  * i.e. the sl_width, sl_height, and planes entrys must be
  10.  * set to fd_w, fd_h, and fd_nplanes. The input pat_run
  11.  * entry should be set to zero, remaining entrys don't care.
  12.  */
  13.  
  14. void mfdb_in_proc(MFDB *mfdb, IBUFPUB *image)
  15. {
  16.   long byte_width, line_offs, plane_size, count;
  17.   char *raster_ptr, *line_ptr, *buf_ptr;
  18.   short num_planes, plane;
  19.  
  20.   raster_ptr = mfdb->fd_addr;
  21.   num_planes = mfdb->fd_nplanes;
  22.   byte_width = (mfdb->fd_w + 7) >> 3;
  23.   line_offs = mfdb->fd_wdwidth << 1;
  24.   plane_size = mfdb->fd_h;
  25.   plane_size *= line_offs;
  26.   for (;;) /* Assume image object handles breakdown. */
  27.   {
  28.     line_ptr = raster_ptr;
  29.     buf_ptr = image->pbuf;
  30.     plane = num_planes;
  31.     do
  32.     { count = byte_width;
  33.       if (byte_width & 1L)
  34.     do *buf_ptr++ = *line_ptr++;
  35.     while (--count);
  36.       else
  37.     do *((short *)buf_ptr)++ =
  38.        *((short *)line_ptr)++;
  39.     while (count -= 2);
  40.       line_ptr -= byte_width;
  41.       line_ptr += plane_size;
  42.     }
  43.     while (--plane > 0);
  44.     image->pbuf = buf_ptr;
  45.     image->bytes_left = 0;
  46.     (*image->put_line)(image);
  47.     raster_ptr += line_offs;
  48. } }
  49.